﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SJZD_NameManage : ATPages
{
    ZSql zsql = new ZSql();

    Function f = new Function();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hfxs.Value = Request.QueryString["moduid"].ToString();
            lblwz.Text = f.getModuleidAdd(hfxs.Value);
            ddlzm1();
            gdata();
         

        }
    }

    protected void btnSelec_Click(object sender, EventArgs e)
    {
        string sql = "select *,hy_name=(select hy_name from CS_Club where id=clup_zid) from CS_ClupMenber";
        if (txtseletype.Text != "")
        {
            if (txtseleband.Text == "")
            {
                if (ddlzm.SelectedValue=="0")
                {
                    sql += " where clup_man like'%" + Common.FormatParameter(txtseletype.Text) + "%'";
                }
                else
                {
                    sql += " where clup_zid ="+ddlzm.SelectedValue+" and clup_man like'%" + Common.FormatParameter(txtseletype.Text) + "%'";
                }

            }

        }
        if (txtseletype.Text != "")
        {
            if (txtseleband.Text != "")
            {
                if (ddlzm.SelectedValue != "0")
                {
                    if (ddlzm.SelectedValue == "00")
                    {
                        sql += " where clup_man like'%" + Common.FormatParameter(txtseletype.Text) + "%' and clup_address like'%" + Common.FormatParameter(txtseleband.Text) + "%' and clup_zid =0";

                    }
                    else
                    {
                        sql += " where clup_man like'%" + Common.FormatParameter(txtseletype.Text) + "%' and clup_address like'%" + Common.FormatParameter(txtseleband.Text) + "%' and clup_zid =" + ddlzm.SelectedValue + "";
                    }
                 
                }
                else
                {
                    sql += " where clup_man like'%" + Common.FormatParameter(txtseletype.Text) + "%' and clup_address like'%" + Common.FormatParameter(txtseleband.Text) + "%'";
                }
            }

        }
        if (txtseletype.Text == "")
        {
            if (txtseleband.Text == "")
            {
                if (ddlzm.SelectedValue != "0")
                {
                    if (ddlzm.SelectedValue == "00")
                    {
                        sql += " where clup_zid =0";

                    }
                    else
                    {
                        sql += " where clup_zid =" + ddlzm.SelectedValue + "";
                    }
                    
                }
                else
                {
                    sql += "";
                }
            }

        }
        if (txtseletype.Text == "")
        {
            if (txtseleband.Text != "")
            {
                if (ddlzm.SelectedValue != "0")
                {
                    if (ddlzm.SelectedValue == "00")
                    {
                        sql += " where clup_address like'%" + Common.FormatParameter(txtseleband.Text) + "%' and clup_zid =0";
                    }
                    else
                    {
                        sql += " where clup_address like'%" + Common.FormatParameter(txtseleband.Text) + "%' and clup_zid =" + ddlzm.SelectedValue + "";
                    }
                   
                }
                else
                {
                    sql += " where clup_address like'%" + Common.FormatParameter(txtseleband.Text) + "%'";
                }
            }

        }
        sql += " order by clup_zid desc";

        PageNavigator1.Total = 1;
        PageNavigator1.Query = sql;

    }

  
    private void gdata()
    {
        string sql = "select *,hy_name=(select hy_name from CS_Club where id=clup_zid) from CS_ClupMenber where clup_zid!=0 order by clup_zid desc";
        PageNavigator1.Total = 1;
        PageNavigator1.Query = sql;
    }
  
    protected void ddlzm1()
    {
        ZSql zm = new ZSql();
        zm.Open("select * from CS_Club");
        ddlzm.DataSource = zm.m_table;
        ddlzm.DataTextField = "hy_name";
        ddlzm.DataValueField = "id";
        ddlzm.DataBind();
        ddlzm.Items.Insert(0, new ListItem("—选择会员组名—", "0"));
        ddlzm.Items.Insert(1, new ListItem("一般客户", "00"));
    
    }
    protected void GvDataName_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (GvDataName.Rows.Count > 0)
        {
            for (int i = 0; i < GvDataName.Rows.Count; i++)
            {
                if (GvDataName.Rows[i].Cells[1].Text == "&nbsp;")
                {
                    GvDataName.Rows[i].Cells[1].Text = "一般客户";
                }
            }
        }
    }
}
